package com.weilx959.spt.plugin.e2sp.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.nio.file.Path;
import java.util.Objects;

/**
 * Excel异常类
 *
 * @author weilx
 * @since 2024-04-30
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class ExcelException extends RuntimeException {
    private final transient Path path;

    public ExcelException() {
        super();
        this.path = null;
    }

    public ExcelException(String message) {
        super(message);
        this.path = null;
    }

    public ExcelException(String message, Throwable cause) {
        super(message, cause);
        this.path = null;
    }

    public ExcelException(Path path, String message) {
        super(message);
        this.path = path;
    }

    public ExcelException(Path path, String message, Throwable cause) {
        super(message, cause);
        this.path = path;
    }

    @Override
    public String getMessage() {
        if (Objects.nonNull(path)) {
            return "[" + path + "]" + super.getMessage();
        }
        return super.getMessage();
    }
}


